<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>Document</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
            list-style: none;
        }

        .main {
            max-width: 750px;
            margin: auto;
        }

        .header {
            height: 400px;
            display: flex;
            align-items: center;
            flex-direction: row-reverse;
            font-size: 2rem;
            padding: 0px 10px;
        }

        .header-result {
            text-align: right;
        }

        .button-box {
            display: flex;
            flex-wrap: wrap;
            background-color: #f1fdfc;
        }

        .button-box>li {
            width: 25%;
            height: 5rem;
            line-height: 5rem;
            text-align: center;
            cursor: pointer;
            
        }

        .button-blue {
            color: #28dedc
        }
    </style>
</head>
<body>
    <main class="main">
        <header class="header">
            <p class="header-result"></p>
        </header>
        <ul class="button-box">
            <li class="button-blue">C</li>
            <li class="button-blue">%</li>
            <li class="button-blue"><-</li>
            <li class="button-blue">/</li>
            <li>7</li>
            <li>8</li>
            <li>9</li>
            <li class="button-blue">X</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li class="button-blue">-</li>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li class="button-blue">+</li>
            <li>00</li>
            <li>0</li>
            <li>.</li>
            <li class="button-blue">=</li>
        </ul>
    </main>
</body>
    <script>
        let btns = document.querySelectorAll(".button-box>li");
        let p = document.querySelector(".header-result");

        for (var v of btns) {
            v.onclick = handleClick;
        }

        function handleClick(e) {
            let btn = e.currentTarget;
            let text = btn.innerText;
            if (text == 'X') {
                text = '*';
            } else if (text == '=') {
                p.innerText = eval(p.innerText);
                return;
            } else if (text == '<-') {
                p.innerText = p.innerText.substring(0,p.innerText.length - 1)
                return;
            } else if (text == 'C') {
                p.innerText = "";
                return;
            }
            p.innerText += text;
        }

    </script>
</html>